#ifndef _SOFTWARE_SPI_H_
#define _SOFTWARE_SPI_H_


typedef struct SPI_CONFIG
{
	unsigned char slave : 1;
	unsigned char CPOL : 1;
	unsigned char CPHA : 1;
	unsigned char finished : 1;
	unsigned char size; //tells the size of the data going in and out.
}
SoftwareSpiConfig;

class SoftwareSpi
{
	private:
		SoftwareSpiConfig config;
		EdgeWatcher watcher;
		BitPointer SS;
		Shifter MISO;
		Shifter MOSI;

		void receiveBit();
		void sendBit();
	public :
		SoftwareSpi(SoftwareSpiConfig c,
			BitPointer& sck,
			BitPointer& miso,
			BitPointer& mosi,
			BitPointer& ss);

		bool getFinished();
		BitArray get();
		void set(BitArray& a);
		virtual void run();	
};







#endif
